// IEC_ShareMemory.cpp native assembly code template.
// KW-Software embedded CLR native assembly builder tool generated source file.
// use this file to implement your own native code

#include "eclr.h"
#include "IEC_ShareMemory.h"


void *pSMemory[20];

/*
	if(address>=1 && address<=33)
	{
		return &g->LocalVar[g->G65_Count][address-1];
	}
	if(address>=100 && address<=199)
	{
		return &PubVar[address-100];
	}
	if(address>=500 && address<=999)
	{
		//x return &g->GParam->MacroKeepVar[address-500];
		return &g_SRAMDATA.MacroKeepVar[address-500];
	}
	if (address>=400 && address<=499)
	{
		return	&SYSTABLE.ToolParam[address-400];
	}
	if(address>=200 && address<=209)
	{
		return &SYSPARAM[address-200];
	}
*/
bool IEC_ShareMemory::init()
{
// if necessary, insert some initialization code for the IEC_ShareMemory library here !
// call IEC_ShareMemory::init() somewhere before IEC_ShareMemory::loadLibrary() is called.
// loadLibrary() have to be called after the ClrContoller object is instanciated
// for detailed information see the native library builder documentation
    return true;
}

bool IEC_ShareMemory::isCompatible(const EclrVersion& requestedVersion)
{
// this function is called by the runtime if an application will be bound
// to this library with the requested version.
// return true means that this library fits to the requested interface.
// return false forces the runtime to search for other libraries with the same name by calling isCompatible()
// if no libraries could be found, the runtime breaks the loading process with linker-error
// for multiple library version support read the documentation.
    return true;
}

bool IEC_ShareMemory::load(ClrAppDomain* pAppDomain)
{
// This function is called by the runtime if an application will be started.
// pAppDomain is the domain object witch hosts the current application process.
// At this point, the firmware library is able to initialize some internal objects.
// If the initialization is done ok, return true
// othewise return false.
    return true;
}

bool IEC_ShareMemory::unload(ClrAppDomain* pAppDomain)
{
// This function is called by the runtime if an application will be terminated.
// pAppDomain is the domain object witch hosts the current application process.
// At this point, the firmware library is able to finalize some internal objects.
// If the finalization is done ok, return true
// othewise return false.
    return true;
}

// class KWFWLibNameSpace.SharedMemoryMacro100 implementation
Void* __PInvoke__ IEC_ShareMemory::SharedMemoryMacro100::GetMemPtr()
{
// implement your code here !
	return pSMemory[SM100];
    return 0;
}

IEC_ShareMemory::SharedMemoryMacro100::SharedMemoryMacro100()
{
// implement your constructor code here !
}

void __PInvoke__ IEC_ShareMemory::SharedMemoryMacro100::ctor()
{
// automatically generated auxiliary contructor : calls the contructor by displacement new operator !
// @Begin automatically generated code, do not modify !
    new (this) IEC_ShareMemory::SharedMemoryMacro100();
// @End automatically generated code
}

// class KWFWLibNameSpace.SharedMemoryMacro200 implementation
Void* __PInvoke__ IEC_ShareMemory::SharedMemoryMacro200::GetMemPtr()
{
// implement your code here !
	return pSMemory[200];
    return 0;
}

IEC_ShareMemory::SharedMemoryMacro200::SharedMemoryMacro200()
{
// implement your constructor code here !
}

void __PInvoke__ IEC_ShareMemory::SharedMemoryMacro200::ctor()
{
// automatically generated auxiliary contructor : calls the contructor by displacement new operator !
// @Begin automatically generated code, do not modify !
    new (this) IEC_ShareMemory::SharedMemoryMacro200();
// @End automatically generated code
}

// class KWFWLibNameSpace.SharedMemoryMacro400 implementation
Void* __PInvoke__ IEC_ShareMemory::SharedMemoryMacro400::GetMemPtr()
{
	return pSMemory[SM400];
// implement your code here !
    return 0;
}

IEC_ShareMemory::SharedMemoryMacro400::SharedMemoryMacro400()
{
// implement your constructor code here !
}

void __PInvoke__ IEC_ShareMemory::SharedMemoryMacro400::ctor()
{
// automatically generated auxiliary contructor : calls the contructor by displacement new operator !
// @Begin automatically generated code, do not modify !
    new (this) IEC_ShareMemory::SharedMemoryMacro400();
// @End automatically generated code
}

// class KWFWLibNameSpace.SharedMemoryMacro500 implementation
Void* __PInvoke__ IEC_ShareMemory::SharedMemoryMacro500::GetMemPtr()
{
// implement your code here !
	return pSMemory[SM500];

    return 0;
}

IEC_ShareMemory::SharedMemoryMacro500::SharedMemoryMacro500()
{
// implement your constructor code here !
}

void __PInvoke__ IEC_ShareMemory::SharedMemoryMacro500::ctor()
{
// automatically generated auxiliary contructor : calls the contructor by displacement new operator !
// @Begin automatically generated code, do not modify !
    new (this) IEC_ShareMemory::SharedMemoryMacro500();
// @End automatically generated code
}

// class KWFWLibNameSpace.SharedMemoryComWrite implementation
Void* __PInvoke__ IEC_ShareMemory::SharedMemoryComWrite::GetMemPtr()
{
// implement your code here !
	return pSMemory[SMCOMW];

    return 0;
}

IEC_ShareMemory::SharedMemoryComWrite::SharedMemoryComWrite()
{
// implement your constructor code here !
}

void __PInvoke__ IEC_ShareMemory::SharedMemoryComWrite::ctor()
{
// automatically generated auxiliary contructor : calls the contructor by displacement new operator !
// @Begin automatically generated code, do not modify !
    new (this) IEC_ShareMemory::SharedMemoryComWrite();
// @End automatically generated code
}

// class KWFWLibNameSpace.SharedMemoryComRead implementation
Void* __PInvoke__ IEC_ShareMemory::SharedMemoryComRead::GetMemPtr()
{
// implement your code here !
	return pSMemory[SMCOMR];
    return 0;
}

IEC_ShareMemory::SharedMemoryComRead::SharedMemoryComRead()
{
// implement your constructor code here !
}

void __PInvoke__ IEC_ShareMemory::SharedMemoryComRead::ctor()
{
// automatically generated auxiliary contructor : calls the contructor by displacement new operator !
// @Begin automatically generated code, do not modify !
    new (this) IEC_ShareMemory::SharedMemoryComRead();
// @End automatically generated code
}

